﻿using B.S.Packaged.ErrorCode;
using B.S.Packaged.WebAPI.Write.Applications.Commands.TeamCommands;
using MediatR;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Packaged.WebAPI.Write.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class TeamController : ControllerBase
    {
        private readonly IMediator mediator;

        public TeamController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 添加交接班
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> CreateTeam(CreateTeamCommands request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 删除交接班信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> DelTeam(DelTeamCommands request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 修改交接班信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> UpdTeam(UpdTeamCommands request)
        {
            return await mediator.Send(request);
        }
    }
}
